package com.aaa.gs;

import com.aaa.gs.config.MyCustomRule;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;

/**
 * fileName:goodsApp
 * description:
 * author: Mr.Ge
 * createTime:2020/11/18 10:35
 * version:1.0.0
 */
@SpringBootApplication
@MapperScan("com.aaa.gs.dao")
@EnableTransactionManagement
@EnableEurekaClient
// name 可以随便起名称，ribbon客户端名称，configuration配置使用的负载均衡策略，
@RibbonClient(name = "goodsRibbon",configuration = MyCustomRule.class)
public class GoodsApp {
    public static void main(String[] args) {
        SpringApplication.run(GoodsApp.class,args);
    }

    /**
     * 初始化RestTemplate
     * @return
     */
    @Bean
    @LoadBalanced  //负载均衡注解
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
